import React, { Component } from 'react'
import style from "./index.module.scss"
import {Swiper } from 'antd-mobile'
import { getBannerListApi } from "@/api/others"
export default class index extends Component {
  state = {
    colorArr: [],
  }
  componentDidMount() {
    this.getBanner()
  }
  async getBanner() {
    let res = await getBannerListApi();
    // console.log(res);
    if (res.data.code===200) {
      this.setState({
        colorArr: res.data.list,
      })
    }
  }
  render() {
    return (
      <div>
        
          <Swiper
            loop
            autoplay
            indicatorProps={{
              color: 'white',
            }}
            defaultIndex={0}
          >
            {this.state.colorArr.map((item, index) => (
              <Swiper.Item key={index+1}>
               { <img src={item.pic} alt={item.name} className={style.img}/>}
              </Swiper.Item>
            ))}
          </Swiper>
        
      </div>
    )
  }
}
